-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[openfga] Configure CloudSQL datastore #15703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
f9ff207
to
798ca4e
Compare
798ca4e
to
7458925
Compare
@@ -28,75 +28,10 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) { | |||
return nil, nil | |||
} | |||
|
|||
containers := []corev1.Container{ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The definition is moved below. If there's config for CloudSQL, we configure the sidecar first and based on that we inject extra envs to the openfga application.
openfgaEnvVars = append(openfgaEnvVars, []corev1.EnvVar{ | ||
{ | ||
Name: "OPENFGA_DATASTORE_ENGINE", | ||
Value: "mysql", | ||
}, | ||
{ | ||
Name: "DB_PASSWORD", | ||
ValueFrom: &corev1.EnvVarSource{SecretKeyRef: &corev1.SecretKeySelector{ | ||
LocalObjectReference: corev1.LocalObjectReference{ | ||
Name: cfg.CloudSQL.DatabaseSecretRef, | ||
}, | ||
Key: "password", | ||
}}, | ||
}, | ||
{ | ||
Name: "DB_USERNAME", | ||
ValueFrom: &corev1.EnvVarSource{SecretKeyRef: &corev1.SecretKeySelector{ | ||
LocalObjectReference: corev1.LocalObjectReference{ | ||
Name: cfg.CloudSQL.DatabaseSecretRef, | ||
}, | ||
Key: "user", | ||
}}, | ||
}, | ||
{ | ||
Name: "OPENFGA_DATASTORE_URI", | ||
Value: fmt.Sprintf("$(DB_USERNAME):$(DB_PASSWORD)@tcp(%s:%d)/%s?parseTime=true", dbHost, CloudSQLProxyPort, cfg.CloudSQL.Instance), | ||
}, | ||
}...) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the core of this PRs change, rest are moves to satisfy declaration dependencies.
/hold I want to validate the cloud-sql-proxy alone works correctly in staging before I land this change. |
Cloud sql has successfully deployed in staging, we can proceed with this /unhold |
LocalObjectReference: corev1.LocalObjectReference{ | ||
Name: cfg.CloudSQL.DatabaseSecretRef, | ||
}, | ||
Key: "password", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How will the real username and password be provided to the env var?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Through a k8s secret, which has been added in this PR https://github.com/gitpod-io/ops/pull/7712
TF loads the secret from GCP into k8s, we reference it through the cfg.CloudSQL.DatabaseSecretRef
config
Description
Related Issue(s)
How to test
Release Notes
Documentation
Werft options:
If enabled this will build
install/preview
Valid options are
all
,workspace
,webapp
,ide
,jetbrains
,vscode
,ssh